package com.wfk.mac.task;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.wfk.service.IAccountService;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.TimeInterval;

import org.apache.log4j.Logger;

@Component
public class EmptyTask {
	@Autowired
	private IAccountService accountService;
	
	private static Logger log = Logger.getLogger(EmptyTask.class); 
	/**
	 * 清空今日收益金额
	 */
	@Scheduled(cron="0 0 0 * * ?")
	//@Scheduled(cron="*/5 * * * * ?")
	public void handleMoneyTask() {
		TimeInterval timer = DateUtil.timer();
		System.out.println("清空今日收益");
		log.info("清空今日收益");
		accountService.handleDayMoney();
		log.info("清空今日收益结束"+timer.interval());
	}
	
	
	@Scheduled(cron="0 0 1 * * ?")
	//@Scheduled(cron="*/7 * * * * ?")
	public void handleMaxMoney() {
		TimeInterval timer = DateUtil.timer();
		log.info("计算每日会员收益开始");
		System.out.println("计算每日会员收益开始");
		try {
			accountService.handleMaxMoney();
		}catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("计算每日会员收益结束"+timer.interval());
		log.info("计算每日会员收益结束");
	}
}

